by Peter Norton and Rob McGregor
In This Chapter
Microsofts Messaging Application Programming Interface (MAPIalso called Mail API) is a messaging architecture that enables applications to interact with multiple messaging systems seamlessly across a variety of hardware platforms. MFC supports a subset of MAPI that allows the transmission of a document through electronic mail to mail-enabled machines. This chapter discusses MAPI, introduces the limited MAPI encapsulation provided by MFC, and presents a basic mail-enabled program.
The Microsoft Messaging API is a complex set of functions you can use to mail-enable your applications, giving them the ability to create, edit, transfer, and store mail messages. The MAPI architecture lets applications work with various messaging systems transparently. MAPI provides messaging services in a generic way because its an open programming interface. This allows developers to customize functionality and provides for future expansion.
MAPI is built into the Windows 95 and Windows NT 4 operating systems. Because MAPI is an integrated part of Windows, application developers have access to a consistent interface. MAPI is split into two interfaces: one for front-end applications and another for the back-end service providers. This division provides true independence from specific messaging systems. This independence is what makes it possible for applications like the Microsoft Exchanges in-box to handle both fax messaging and Internet mail services, as well as LAN workgroup messaging. The MAPI programming interfaces provide the features developers need to mail-enable workgroup applications that deal with various messaging systems such as fax, voice mail, and online services like CompuServe and MCI MAIL.
MAPI for Win32 is found in the dynamic link library MAPI32.DLL. MAPI-compliant objects use the Component Object Model (COM) to define their behavior. Also, MAPI is the messaging component of the Microsoft Windows Open Services Architecture (WOSA). WOSA is an open architecture standard that is currently evolving for use with not only messaging, but database, security, and other technologies as well.
Note:The Microsoft Windows Open Services Architecture allows you to develop both front-end and back-end software using a standardized interface that fits easily into the distributed computing model.
MAPI client applications come in three general types:
A couple of higher-level interface alternatives to the MAPI specification are available to Windows programmers on PC platforms. These abstractions are called Simple MAPI and Common Messaging Calls (CMC). This implementation supports existing messaging-enabled and messaging-aware Windows applications developed in any language that supports DLLs, including C, C++, Delphi, and Visual Basic. Simple MAPI gives you the tools to add basic messaging services to your applications.
When writing messaging-enabled and messaging-aware applications, either Simple MAPI or CMC is an appropriate MAPI interface choice. These interfaces are nearly identical; both provide a set of functions that lets clients create, send, receive, reply to, forward, edit, and delete messages.
The Simple MAPI specification uses the MAPI32.DLL library, just as the full MAPI specification does. There are 12 functions in Simple MAPI that give an application the power to send, address, receive, and reply to messages. Table 27.1 describes the functions provided by Simple MAPI.
| Simple MAPI Function | Purpose |
|---|---|
| MAPIAddress() | Addresses a message. |
| MAPIDeleteMail() | Deletes a message. |
| MAPIDetails() | Displays a recipient-details dialog box. |
| MAPIFindNext() | Returns the identifier of the first or next message of a specified type. |
| MAPIFreeBuffer() | Frees memory allocated by the messaging system. |
| MAPILogoff() | Ends a session with the messaging system. |
| MAPILogon() | Establishes a messaging session. |
| MAPIReadMail() | Reads a message. |
| MAPIResolveName() | Displays a dialog box to resolve an ambiguous recipient name. |
| MAPISaveMail() | Saves a message. |
| MAPISendDocuments() | Sends a standard message using a dialog box. |
| MAPISendMail() | Sends a message, allowing greater flexibility in message generation than MAPISendDocuments() does. |